﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Studio.InfoPlus.BusinessServices.Entities
{

    /// <summary>
    /// Renderable element that can be used as a container and layout otherss
    /// the known layoutables are: 
    /// 1. table (includes td, tr, th...)
    /// 2. div
    /// </summary>
    public class Layoutable : Renderable
    {

        IList<Layoutable> layouts = new List<Layoutable>();

        public IList<Layoutable> Layouts
        {
            get { return layouts; }
            set { layouts = value; }
        }

        IList<Displayable> controls = new List<Displayable>();

        public IList<Displayable> Controls
        {
            get { return controls; }
            set { controls = value; }
        }

        /// <summary>
        /// Layout level repeat only.
        /// </summary>
        bool Repeatable { get; set; }

        /// <summary>
        /// 
        /// </summary>
        public void AddRenderable(Renderable render)
        {
            if (render is Layoutable && false == layouts.Contains(render as Layoutable))
            {
                this.layouts.Add(render as Layoutable);
            }
            else if (render is Displayable && false == this.controls.Contains(render as Displayable))
            {
                this.controls.Add(render as Displayable);
            }
            else 
            { 
                // Extensible
            }
        }
    }
}
